package caiziyou.com.designpattern.factory.absfactory.order;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import caiziyou.com.designpattern.factory.absfactory.pizza.Pizza;


public class OrderPizza {
	private AbsFactory absFactory;
	public OrderPizza(AbsFactory absFactory) {
		Pizza pizza = null;
		this.absFactory = absFactory;
		do {
			pizza = this.absFactory.createPizza(getType());
			if(pizza != null) {
				System.out.println("订购pizza完成");
			}else {
				System.out.println("订购失败，程序结束");
				break;
			}
		} while (true);
	}

	public String getType() {

		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		try {
			System.out.println("input pizza type:");
			return bufferedReader.readLine();
		} catch (IOException e) {

			return "";
		}
	}
}
